var app = getApp();
Component({
    properties: {
        list: Array,
        tag: String,
        type: String,
        hidebrd: Number,
        iscard: Number,
        stylea: Number,
        params: Object,
        info: Object,
        issearch: Number,
        issx: Number,
        dropdown: Object,
    },
    data: {
        showstatus: false,
        page: {
            isend: false,
            doing: false,
            doo: 'shop',
            pdata: {
                op: 'indexlist',
                num: 10,
                page: 2,
                otype: 0,
                sortid: 0,
                sorttwo: 0,
                city: 0,
                lat: 0,
                lng: 0,
                search: '',
                ordertype: 0,
                trade: 0,
            },
            waitf: 0,
            nodataf: 0,
        },
    },
    options: {
        addGlobalClass: true,
    },
    ready() {
        var self = this;
        var item = self.data.info || {};
        for (var t in item) {
            self.data.page.pdata[t] = item[t];
        }
    },
    methods: {
        play(e) {
            var url = e.target.id
            const gv = app.globalData.videoNumber
            if (url != gv && gv != null) {
                var videoContext = wx.createVideoContext(gv, this) //这里对应的视频id
                videoContext.pause()
            }
            app.globalData.videoNumber = url
        },
        navigateto(e) {
            app.com.navigateto(e);
        },
        location: function (e) {
            app.com.location(e);
        },
        searchshopfn(e) {
            var self = this;
            if (self.data.ising) return false;
            self.data.ising = true;
            self.data.page.pdata.search = e.detail;
            self.data.ising = false;
            self.reset('search');
        },
        changesortone(e) {
            var self = this;
            if (self.data.ising) return false;
            self.data.ising = true;
            self.data.page.pdata.search = '';
            self.data.ising = false;
            self.data.page.isend = false;
            self.data.page.doing = false;
            self.data.page.waitf = 0;
            self.data.page.nodataf = 0;
            self.data.page.pdata.page = 1;
            self.data.list = [];
            self.data.page.pdata[e.currentTarget.dataset.type] = e.detail;
            self.reset('search');
        },
        clears() {
            var e = {
                detail: '',
            };
            this.searchshopfn(e);
        },
        reset(e) {
            this.data.page.isend = false;
            this.data.page.doing = false;
            this.data.page.waitf = 0;
            this.data.page.nodataf = 0;
            this.data.page.pdata.page = 1;
            this.data.list = [];
            this.load(e ? e : 'reset');
        },
        load(e) {
            var self = this;
            if (self.data.info.isdown != 1 && e != 'search') return false;
            app.com.getPage(self, self.data.page, 20, false, function (res) {
                if (e == 'reset' || e == 'search') {
                    self.setData({
                        list: res.data.data.list
                    });
                } else {
                    self.setData({
                        list: self.data.list.concat(res.data.data.list)
                    });
                }
            });
        },
    }
})